syntax = "proto3";

package nighthawk.client;

import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "envoy/config/core/v3/base.proto";

import "api/client/options.proto";

message Counter {
  string name = 1;
  uint64 value = 2;
}

message Percentile {
  oneof duration_type {
    google.protobuf.Duration duration = 1;
    double raw_value = 4;
  }
  double percentile = 2;
  uint64 count = 3;
}

message Statistic {
  uint64 count = 1;
  string id = 2;
  oneof mean_type {
    google.protobuf.Duration mean = 3;
    double raw_mean = 8;
  }
  oneof pstdev_type {
    google.protobuf.Duration pstdev = 4;
    double raw_pstdev = 10;
  }
  repeated Percentile percentiles = 5;
  oneof min_type {
    google.protobuf.Duration min = 6;
    uint64 raw_min = 12;
  }
  oneof max_type {
    google.protobuf.Duration max = 7;
    uint64 raw_max = 13;
  }
}

// An output generated by a UserDefinedOutput plugin.
message UserDefinedOutput {
  // The official name of the plugin as registered through Envoy's plugin registration system.
  string plugin_name = 1;
  oneof output_type {
    // The typed output defined by the plugin containing specific data that the plugin collected.
    google.protobuf.Any typed_output = 2;
    // The error returned by the plugin when trying to generate the output.
    string error_message = 3;
  }
}

// The set of output collected by Nighthawk for each worker, or for the aggregate of all workers.
message Result {
  // Either the name of the worker this result correlates to, or "global" for the aggregated
  // output.
  string name = 1;
  repeated Statistic statistics = 2;
  repeated Counter counters = 3;
  google.protobuf.Duration execution_duration = 4;
  google.protobuf.Timestamp execution_start = 5;

  // Outputs generated by User Defined Output Plugins. Plugin outputs are not guaranteed to be
  // returned in the same order the user_defined_plugin_configs are provided in the request.
  // To determine which plugin each output goes to, use the UserDefinedOutput's plugin_name field.
  repeated UserDefinedOutput user_defined_outputs = 6;
}

// The full set of output returned by a Nighthawk run, including the Results from every worker.
message Output {
  google.protobuf.Timestamp timestamp = 1;
  nighthawk.client.CommandLineOptions options = 2;
  repeated Result results = 3;
  envoy.config.core.v3.BuildVersion version = 4;
}
